package org.jeecg.modules.business.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import org.jeecg.modules.business.entity.IotManufacturer;
import org.jeecg.modules.business.service.IotManufacturerService;
import org.jeecg.modules.business.vo.IotManufacturerVO;
import org.jeecg.modules.business.vo.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author:Gan Linghao
 * @date:2020/7/14 0014
 * @time:16:34
 * @description:no description
 */
@RestController
@RequestMapping("/api/v1/iotManufacturer")
@Api(tags = "厂家信息接口")
public class IotManufacturerController {

    Logger log = LoggerFactory.getLogger(getClass());

    @Autowired
    private IotManufacturerService iotManufacturerService;

    /**
     *厂家列表
     * @return
     */
    @GetMapping(value = "/list")
    @ResponseBody
    public Result<Page<IotManufacturerVO>> list(@RequestParam(value = "name", required = false)String name, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        Result<Page<IotManufacturerVO>> result = new Result<>();

        try {
            Page<IotManufacturerVO> page = new Page<>(pageNo,pageSize);
            page.setRecords(iotManufacturerService.selectListPage(page,name));
            result.setResult(page);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
            result.error500("获取数据失败！");
        }
        return result;
    }

    @PostMapping("/add")
    public void add(@RequestBody IotManufacturer iot){
        System.out.println("对象：" + iot.toString());
    }
}

